
#include "lib.h"

#include "kenocard.h"
#include "kenobet.h"

KenoBet::KenoBet(int32 num_cards)
{
	m_total_cards = num_cards;
	m_num_cards = 0;

	m_cards = new KenoCard[num_cards];

	if(!m_cards)
		m_total_cards = 0;
}

KenoBet::~KenoBet()
{
	delete [] m_cards;
	m_cards = (KenoCard *)0;
	m_total_cards = 0;
	m_num_cards = 0;
}

int32 
KenoBet::GetNumCards() 
{ 
	return m_num_cards; 
}

int32 
KenoBet::GetTotalBet()
{
	int32 total_cost = 0;
	for(int32 i = 0; i < m_num_cards; i++)
	{
		total_cost += m_cards[i].GetCost();
	}
	return total_cost;
}

int32 
KenoBet::GetCardCost()
{
	return m_card_cost;
}

void 
KenoBet::SetCardCost(int32 cost)
{
	m_card_cost = cost;
}

KenoCard *
KenoBet::GetCard(int i)
{
	if(i < 0 || i >= m_num_cards) 
		return (KenoCard *)0;

	return &m_cards[i];
}

bool8 
KenoBet::IsValid()
{
	return (m_cards && m_num_cards > 0);
}

bool8 
KenoBet::PlayCard(KenoCard &card)
{
	if(m_num_cards < m_total_cards)
	{
		m_cards[m_num_cards++] = card;
		return true;
	}
	else
		return false;
}

int32 KenoBet::m_card_cost = 0;


